<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form id ="f1">
        <input type="text" id="username" />
        <input type="password" id="pwd" />
        <input type="submit" value="注册" id="sub" />
    </form>
</body>
<script>
    var f1 = document.getElementById("f1");
    var us = document.getElementById("username");
    var pa = document.getElementById("pwd");
    var su = document.getElementById("sub");
    f1.onsubmit = function(){
        alert("成功提交至胖哥服务器");
    }
    us.onblur = function(){
        var val = username.value;
        if(val.length < 3){
        alert("胖哥提醒：姓名要写汉字哦");
        }
    }
    pa.onfocus = function(){
        var val2 = pwd.value;
        if(val2.length < 6){
            alert("胖哥提醒：嘎哈呢");
        }
    }
</script>
</html>